package info

import (
	"fmt"
	"time"

	//"github.com/StackExchange/wmi"
	"github.com/yusufpapurcu/wmi"
)

// 风扇
type CIM_Fan struct {
	ActiveCooling               bool
	Availability                uint16
	Caption                     string
	ConfigManagerErrorCode      uint32
	ConfigManagerUserConfig     bool
	CreationClassName           string
	Description                 string
	DesiredSpeed                uint64
	DeviceID                    string
	ErrorCleared                bool
	ErrorDescription            string
	InstallDate                 time.Time
	LastErrorCode               uint32
	Name                        string
	PNPDeviceID                 string
	PowerManagementCapabilities []uint16
	PowerManagementSupported    bool
	Status                      string
	StatusInfo                  uint16
	SystemCreationClassName     string
	SystemName                  string
}

type Win32_DisplayControllerConfiguration struct {
	Caption                      string
	Description                  string
	SettingID                    string
	BitsPerPixel                 int32
	ColorPlanes                  int32
	DeviceEntriesInAColorTable   int32
	DeviceSpecificPens           int32
	HorizontalResolution         int32
	Name                         string
	RefreshRate                  int32
	ReservedSystemPaletteEntries int32
	SystemPaletteEntries         int32
	VerticalResolution           int32
	VideoMode                    string
}

type CIM_NetworkAdapter struct {
	AutoSense               bool
	Availability            uint16
	Caption                 string
	ConfigManagerErrorCode  uint32
	ConfigManagerUserConfig bool
	CreationClassName       string
	Description             string
	DeviceID                string
	ErrorCleared            bool
	ErrorDescription        string
	//InstallDate                 time.Time
	LastErrorCode               uint32
	MaxSpeed                    uint64
	Name                        string
	NetworkAddresses            string
	PermanentAddress            string
	PNPDeviceID                 string
	PowerManagementCapabilities []uint16
	PowerManagementSupported    bool
	Speed                       uint64
	Status                      string
	StatusInfo                  uint16
	SystemCreationClassName     string
	SystemName                  string
}

func FanInfo() {
	var info []CIM_Fan
	err1 := wmi.Query("Select * from CIM_Fan", &info)
	if err1 != nil {

		fmt.Printf("错误:%s\n", err1)
		return
	}
	fmt.Printf("%#v", info[0])
}

func NetAdapterInfo1() {
	var info []CIM_NetworkAdapter
	err1 := wmi.Query("Select * from CIM_NetworkAdapter", &info)
	if err1 != nil {

		fmt.Printf("错误:%s\n", err1)
		return
	}
	fmt.Printf("%#v", info)
}

func NetworkAdapterConfigurationInfo() {
	var info []Win32_NetworkAdapterConfiguration
	err1 := wmi.Query("Select * from Win32_NetworkAdapterConfiguration", &info)
	if err1 != nil {
		fmt.Printf("错误:%s\n", err1)
		return
	}
	fmt.Printf("%#v", info)
}
